class Task6Recursive:
    def run(self, head):
        result = []
        self.run_inner(head, result)
        return result

    def run_inner(self, head, result):
        if head is None:
            return
        self.run_inner(head.next, result)
        result.append(head.val)


class Task6Stack:
    def run(self, head):
        result = []
        stack = []
        node = head
        while node is not None:
            stack.append(node.val)
            node = node.next

        while len(stack) > 0:
            result.append(stack.pop())
        return result
